var Youh3s = document.querySelectorAll(".hotCakesYou li h3")// 获取商品列表中每一个分类的标题
    var Youboxs = document.querySelectorAll(".hotCakesYou-box")// 获取每一个分类的商品列表
    var hotCul = document.querySelector(".hotCakes")// 获取导航列表
    var hotClis = document.querySelectorAll(".hotCakes li");// 获取导航列表标题
    var hotCakesYou = document.querySelector(".hotCakesYou")
    var scrollTop = hotCakesYou.scrollTop
    // （一）点击导航标题，使商品列表滚动
    for (let i = 0; i < hotClis.length; i++) {
        hotClis[i].onclick = function () {
            // 首先获取当前网页滚动位置
            // console.log(this);
            // console.log(this.offsetTop);
            var scrollTop = hotCakesYou.scrollTop;
            var targetTop = Youh3s[i].offsetTop;
            var offsetTop = targetTop - scrollTop;
            var y = offsetTop / 50;
            var count = 0;
            function move() {
                count++;
                hotCakesYou.scrollBy(0, y);
                if (count < 50) {
                    requestAnimationFrame(move)
                }else {
                    requestAnimationFrame(function () {
                        hotCakesYou.scrollTo(0, targetTop)
                    })
                }
            }
            requestAnimationFrame(move)
        }
    }
 
 
    hotCakesYou.onscroll = function () {
        var scrollTop = hotCakesYou.scrollTop;
        Array.from(Youh3s).forEach(function (Youh3, i) {
            if (Youh3.offsetTop < scrollTop + 100) {
                for (const li of hotClis) {
                    li.classList.remove("xz")
                }
                hotClis[i].classList.add("xz")
            }
        })
    }
    // 搜索
    window.onscroll = function () {
        var scrollTop = document.body.scrollTop || document.documentElement.scrollTop
        if (scrollTop > 120) {
            document.querySelector(".header-box").classList.add("header-box-position")
        } else {
            document.querySelector(".header-box").classList.remove("header-box-position")
        }
    }